<template>
  <!-- 注入antd语言 -->
  <a-config-provider :locale="locale">
    <div id="app">
      <!-- 注入theme -->
      <ThemeProvider :theme="theme.data" style="width: 100%; height: 100%;">
        <AppStyleWrapper>
          <router-view v-if="isRouterAlive" ></router-view>
          <SettingDrawer></SettingDrawer>
        </AppStyleWrapper>
      </ThemeProvider>
    </div>
  </a-config-provider>
</template>

<script>
import { mapGetters } from 'vuex'
import { ThemeProvider } from 'vue-styled-components'
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import { AppStyleWrapper } from '@/common/styles/commonStyle'
import SettingDrawer from '@/components/SettingDrawer/index'

export default {
  name: 'app',
  components: {
    ThemeProvider,
    AppStyleWrapper,
    SettingDrawer,
  },
  computed: {
    ...mapGetters(['theme', 'isRouterAlive', 'config', 'token']),
  },
  data () {
    return {
      locale: zhCN,
    }
  },
  mounted () {
    if (this.token) {
      // this.$store.dispatch('checkToken')
      //   .then(res => {
      // if (res.result.valid) {
      this.$store.dispatch('getUserInfo')
      this.$store.dispatch('getMenuAndPermissions')
      // } else {
      // this.$message.warn({
      // content: '跳转登录'
      // })
      // this.$store.dispatch('logout')
      // }
      // })
      // .catch(() => {
      //   this.$store.dispatch('getUserInfo')
      //   this.$store.dispatch('getMenuAndPermissions')
      // })
    }
  },
  methods: {
  }
}
</script>

<style lang="scss">
#app{
  width: 100%;
  height: 100%;
}
</style>
